<template>
<div id="item" @click="changepage">
  <div v-if="!isactive"><slot name="item-icon" ></slot></div>
  <div v-else><slot name="item-icon-active"></slot></div>
  <div :style="activustyle"><slot name="text"></slot></div>
    
</div>
  
</template>

<script>
export default {
  name:'tabbaritem',
  data(){
    return{}
  },
  methods:{

changepage(){
  this.$router.push(this.path)
}
  },
  props:{
    path:String,
    activecolor:{
      type:String,
      default:'blue'
    }
  },
  computed:{
    isactive(){
      return this.$route.path.indexOf(this.path) !==-1
    },
    activustyle(){
      return this.isactive ? {color:this.activecolor}:{}
    }
    

  }
}
</script>

<style scoped>
  #item{
    flex: 1;
    text-align: center;
    height: 49px;
    font-size: 14px;
    float:left;
    width: 25%;
  
  }

  #item img
  {
    width: 24px;
    height: 24px;
    margin-top: 3px;
    vertical-align: middle;
    margin-bottom: 2px;
  }

</style>